#include "widget.h"
#include "ui_widget.h"
#include <QMessageBox>


int step = 0;

QString question[] =
{
    "老公的生日是什么时辰",
    "老公的身高是",
    "老公和易烊千玺谁帅",
    "用最美的话语夸赞老公"
};

QString answer1[] =
{
    "A.子时",
    "B.丑时",
    "C.未时",
    "D.酉时"
};

QString position1 = "第一个宝贝在大房间猫爬上去的天花板上面，快去找吧";

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    dialog = new QDialog(this);//创建对话框对象
//    dialogNG = new QDialog(this);


    dialog->setWindowTitle("这你也能错？");
    dialog->resize(200,100);
//    dialogNG->resize(200,100);
}

Widget::~Widget()
{
    delete ui;
    delete dialog;
}

void Widget::Correct()
{
    step++;
    QMessageBox::information(dialog, tr("正确"),
                                            tr(position1.toStdString().c_str()), QMessageBox::Ok);
}

void Widget::UnCorrect()
{
    dialog->setWindowTitle("这你也能错？");
}

void Widget::connect2Dialog(QPushButton *button)
{
    connect(button,&QPushButton::clicked,dialog,&QDialog::open);
    connect(button,&QPushButton::clicked,this,Correct);
}

void Widget::disconnect2Dialog(QPushButton *button)
{
    disconnect(button,0,0,0);
}

void Widget::processOn()
{
    switch (step)
    {
        case 0:
            connect2Dialog(ui->pushButton_A);
            break;
        case 1:
            disconnect2Dialog(ui->pushButton_A);
            connect2Dialog(ui->pushButton_B);
            break;
        case 2:
            disconnect2Dialog(ui->pushButton_B);
            connect2Dialog(ui->pushButton_C);
            break;
        case 3:
            disconnect2Dialog(ui->pushButton_D);
            connect2Dialog(ui->pushButton_D);
            dialog->setWindowTitle("不够，继续说");
            break;
        case 4:
            break;
        default:
            break;
    }
}
